.class public Lcom/netease/newsreader/download/AppUpdateService;
.super Landroid/app/Service;
.source "AppUpdateService.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/netease/newsreader/download/AppUpdateService$DownloadBean;,
        Lcom/netease/newsreader/download/AppUpdateService$UpdateThread;
    }
.end annotation


# static fields
.field public static final MSG_DOWNLOAD:I = 0x1

.field public static final MSG_ERROR:I = 0x2

.field private static final UPDATEURL:Ljava/lang/String; = "http://file.ws.126.net/3g/client/netease_newsreader_android.apk"


# instance fields
.field currentTimeMillis:J

.field mAutoid:I

.field mDownLoader:Lcom/netease/newsreader/download/FileDownloader;

.field private mMessageCount:I

.field private mNotification:Landroid/app/Notification;

.field private mNotificationManager:Landroid/app/NotificationManager;

.field mTotalSize:J

.field private mUpdateThread:Lcom/netease/newsreader/download/AppUpdateService$UpdateThread;

.field private mWakeLock:Landroid/os/PowerManager$WakeLock;

.field private mWifiLock:Landroid/net/wifi/WifiManager$WifiLock;

.field private pIntent:Landroid/app/PendingIntent;

.field private remoteView:Landroid/widget/RemoteViews;

.field title:Ljava/lang/String;


# direct methods
.method public constructor <init>()V
    .locals 3

    .prologue
    const-wide/16 v1, 0x0

    .line 28
    invoke-direct {p0}, Landroid/app/Service;-><init>()V

    .line 34
    iput-wide v1, p0, Lcom/netease/newsreader/download/AppUpdateService;->mTotalSize:J

    .line 35
    const/16 v0, 0x2710

    iput v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mAutoid:I

    .line 36
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mDownLoader:Lcom/netease/newsreader/download/FileDownloader;

    .line 38
    const-string v0, "\u7f51\u6613\u65b0\u95fb"

    iput-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->title:Ljava/lang/String;

    .line 46
    iput-wide v1, p0, Lcom/netease/newsreader/download/AppUpdateService;->currentTimeMillis:J

    .line 49
    const/4 v0, 0x0

    iput v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mMessageCount:I

    .line 28
    return-void
.end method

.method static synthetic access$0(Lcom/netease/newsreader/download/AppUpdateService;J)Ljava/lang/String;
    .locals 1
    .parameter
    .parameter

    .prologue
    .line 239
    invoke-direct {p0, p1, p2}, Lcom/netease/newsreader/download/AppUpdateService;->getSoftwareSize(J)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method static synthetic access$1(Lcom/netease/newsreader/download/AppUpdateService;Landroid/app/PendingIntent;)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 47
    iput-object p1, p0, Lcom/netease/newsreader/download/AppUpdateService;->pIntent:Landroid/app/PendingIntent;

    return-void
.end method

.method static synthetic access$2(Lcom/netease/newsreader/download/AppUpdateService;IILjava/lang/String;I)V
    .locals 0
    .parameter
    .parameter
    .parameter
    .parameter
    .parameter

    .prologue
    .line 106
    invoke-direct {p0, p1, p2, p3, p4}, Lcom/netease/newsreader/download/AppUpdateService;->setNotification(IILjava/lang/String;I)V

    return-void
.end method

.method static synthetic access$3(Lcom/netease/newsreader/download/AppUpdateService;)Landroid/widget/RemoteViews;
    .locals 1
    .parameter

    .prologue
    .line 43
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->remoteView:Landroid/widget/RemoteViews;

    return-object v0
.end method

.method static synthetic access$4(Lcom/netease/newsreader/download/AppUpdateService;)Landroid/app/NotificationManager;
    .locals 1
    .parameter

    .prologue
    .line 39
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mNotificationManager:Landroid/app/NotificationManager;

    return-object v0
.end method

.method static synthetic access$5(Lcom/netease/newsreader/download/AppUpdateService;)Landroid/app/Notification;
    .locals 1
    .parameter

    .prologue
    .line 44
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mNotification:Landroid/app/Notification;

    return-object v0
.end method

.method static synthetic access$6(Lcom/netease/newsreader/download/AppUpdateService;)I
    .locals 1
    .parameter

    .prologue
    .line 49
    iget v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mMessageCount:I

    return v0
.end method

.method static synthetic access$7(Lcom/netease/newsreader/download/AppUpdateService;I)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 49
    iput p1, p0, Lcom/netease/newsreader/download/AppUpdateService;->mMessageCount:I

    return-void
.end method

.method private acquireLock()V
    .locals 1

    .prologue
    .line 90
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWakeLock:Landroid/os/PowerManager$WakeLock;

    if-eqz v0, :cond_0

    .line 91
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWakeLock:Landroid/os/PowerManager$WakeLock;

    invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->acquire()V

    .line 92
    :cond_0
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWifiLock:Landroid/net/wifi/WifiManager$WifiLock;

    if-eqz v0, :cond_1

    .line 93
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWifiLock:Landroid/net/wifi/WifiManager$WifiLock;

    invoke-virtual {v0}, Landroid/net/wifi/WifiManager$WifiLock;->acquire()V

    .line 94
    :cond_1
    return-void
.end method

.method private getSoftwareSize(J)Ljava/lang/String;
    .locals 8
    .parameter "size"

    .prologue
    const/4 v7, 0x2

    const-wide/32 v5, 0x100000

    .line 241
    const-string v0, "0.00M"

    .line 243
    .local v0, rst:Ljava/lang/String;
    cmp-long v2, p1, v5

    if-gez v2, :cond_0

    .line 244
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-wide/16 v3, 0x400

    div-long v3, p1, v3

    invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "K"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 253
    :goto_0
    return-object v0

    .line 246
    :cond_0
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    rem-long v3, p1, v5

    invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 247
    .local v1, temp:Ljava/lang/String;
    invoke-virtual {v1}, Ljava/lang/String;->length()I

    move-result v2

    if-le v2, v7, :cond_1

    .line 248
    const/4 v2, 0x0

    invoke-virtual {v1, v2, v7}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v1

    .line 250
    :cond_1
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    div-long v3, p1, v5

    invoke-virtual {v2, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "."

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "M"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    goto :goto_0
.end method

.method private releaseLock()V
    .locals 1

    .prologue
    .line 97
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWifiLock:Landroid/net/wifi/WifiManager$WifiLock;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWifiLock:Landroid/net/wifi/WifiManager$WifiLock;

    invoke-virtual {v0}, Landroid/net/wifi/WifiManager$WifiLock;->isHeld()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 98
    const-string v0, "TThread releaseLock mWifiLock"

    invoke-static {v0}, Lcom/netease/newsreader/util/Logger;->i(Ljava/lang/String;)V

    .line 99
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWifiLock:Landroid/net/wifi/WifiManager$WifiLock;

    invoke-virtual {v0}, Landroid/net/wifi/WifiManager$WifiLock;->release()V

    .line 101
    :cond_0
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWakeLock:Landroid/os/PowerManager$WakeLock;

    if-eqz v0, :cond_1

    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWakeLock:Landroid/os/PowerManager$WakeLock;

    invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->isHeld()Z

    move-result v0

    if-eqz v0, :cond_1

    .line 102
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWakeLock:Landroid/os/PowerManager$WakeLock;

    invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->release()V

    .line 104
    :cond_1
    return-void
.end method

.method private setNotification(IILjava/lang/String;I)V
    .locals 2
    .parameter "layoutId"
    .parameter "notifyId"
    .parameter "desc"
    .parameter "flags"

    .prologue
    .line 107
    new-instance v0, Landroid/widget/RemoteViews;

    invoke-virtual {p0}, Lcom/netease/newsreader/download/AppUpdateService;->getPackageName()Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1, p1}, Landroid/widget/RemoteViews;-><init>(Ljava/lang/String;I)V

    iput-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->remoteView:Landroid/widget/RemoteViews;

    .line 109
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mNotification:Landroid/app/Notification;

    iput p2, v0, Landroid/app/Notification;->icon:I

    .line 110
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mNotification:Landroid/app/Notification;

    iget-object v1, p0, Lcom/netease/newsreader/download/AppUpdateService;->remoteView:Landroid/widget/RemoteViews;

    iput-object v1, v0, Landroid/app/Notification;->contentView:Landroid/widget/RemoteViews;

    .line 111
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mNotification:Landroid/app/Notification;

    iget-object v1, p0, Lcom/netease/newsreader/download/AppUpdateService;->pIntent:Landroid/app/PendingIntent;

    iput-object v1, v0, Landroid/app/Notification;->contentIntent:Landroid/app/PendingIntent;

    .line 112
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mNotification:Landroid/app/Notification;

    iput p4, v0, Landroid/app/Notification;->flags:I

    .line 114
    return-void
.end method


# virtual methods
.method public getFileName(Ljava/lang/String;)Ljava/lang/String;
    .locals 1
    .parameter "url"

    .prologue
    .line 117
    const-string v0, "/"

    invoke-virtual {p1, v0}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I

    move-result v0

    add-int/lit8 v0, v0, 0x1

    invoke-virtual {p1, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public onBind(Landroid/content/Intent;)Landroid/os/IBinder;
    .locals 1
    .parameter "intent"

    .prologue
    .line 80
    const/4 v0, 0x0

    return-object v0
.end method

.method public onCreate()V
    .locals 7

    .prologue
    .line 54
    invoke-super {p0}, Landroid/app/Service;->onCreate()V

    .line 55
    const-string v2, "notification"

    invoke-virtual {p0, v2}, Lcom/netease/newsreader/download/AppUpdateService;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/app/NotificationManager;

    iput-object v2, p0, Lcom/netease/newsreader/download/AppUpdateService;->mNotificationManager:Landroid/app/NotificationManager;

    .line 57
    const-string v2, "power"

    invoke-virtual {p0, v2}, Lcom/netease/newsreader/download/AppUpdateService;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/os/PowerManager;

    .line 58
    .local v0, powerManager:Landroid/os/PowerManager;
    const/4 v2, 0x1

    const-string v3, "UpdateThread"

    invoke-virtual {v0, v2, v3}, Landroid/os/PowerManager;->newWakeLock(ILjava/lang/String;)Landroid/os/PowerManager$WakeLock;

    move-result-object v2

    iput-object v2, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWakeLock:Landroid/os/PowerManager$WakeLock;

    .line 60
    const-string v2, "wifi"

    invoke-virtual {p0, v2}, Lcom/netease/newsreader/download/AppUpdateService;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/net/wifi/WifiManager;

    .line 61
    .local v1, wifiManager:Landroid/net/wifi/WifiManager;
    const-string v2, "UpdateThread"

    invoke-virtual {v1, v2}, Landroid/net/wifi/WifiManager;->createWifiLock(Ljava/lang/String;)Landroid/net/wifi/WifiManager$WifiLock;

    move-result-object v2

    iput-object v2, p0, Lcom/netease/newsreader/download/AppUpdateService;->mWifiLock:Landroid/net/wifi/WifiManager$WifiLock;

    .line 63
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v2

    iput-wide v2, p0, Lcom/netease/newsreader/download/AppUpdateService;->currentTimeMillis:J

    .line 65
    new-instance v2, Landroid/app/Notification;

    const v3, 0x7f0200f5

    const-string v4, "\u65b0\u7248\u672c\u5df2\u7ecf\u5f00\u59cb\u66f4\u65b0"

    iget-wide v5, p0, Lcom/netease/newsreader/download/AppUpdateService;->currentTimeMillis:J

    invoke-direct {v2, v3, v4, v5, v6}, Landroid/app/Notification;-><init>(ILjava/lang/CharSequence;J)V

    iput-object v2, p0, Lcom/netease/newsreader/download/AppUpdateService;->mNotification:Landroid/app/Notification;

    .line 67
    invoke-direct {p0}, Lcom/netease/newsreader/download/AppUpdateService;->acquireLock()V

    .line 68
    return-void
.end method

.method public onDestroy()V
    .locals 0

    .prologue
    .line 85
    invoke-super {p0}, Landroid/app/Service;->onDestroy()V

    .line 86
    invoke-direct {p0}, Lcom/netease/newsreader/download/AppUpdateService;->releaseLock()V

    .line 87
    return-void
.end method

.method public onStart(Landroid/content/Intent;I)V
    .locals 2
    .parameter "intent"
    .parameter "startId"

    .prologue
    .line 73
    new-instance v0, Lcom/netease/newsreader/download/AppUpdateService$UpdateThread;

    const-string v1, "http://file.ws.126.net/3g/client/netease_newsreader_android.apk"

    invoke-direct {v0, p0, p0, v1}, Lcom/netease/newsreader/download/AppUpdateService$UpdateThread;-><init>(Lcom/netease/newsreader/download/AppUpdateService;Landroid/content/Context;Ljava/lang/String;)V

    iput-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mUpdateThread:Lcom/netease/newsreader/download/AppUpdateService$UpdateThread;

    .line 74
    iget-object v0, p0, Lcom/netease/newsreader/download/AppUpdateService;->mUpdateThread:Lcom/netease/newsreader/download/AppUpdateService$UpdateThread;

    invoke-virtual {v0}, Lcom/netease/newsreader/download/AppUpdateService$UpdateThread;->start()V

    .line 75
    return-void
.end method
